package com.example.diethealthsystem.service;

import com.example.diethealthsystem.entity.DietPlanItem;
import com.example.diethealthsystem.repository.DietPlanItemRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class DietPlanItemService {

    private final DietPlanItemRepository dietPlanItemRepository;

    @Autowired
    public DietPlanItemService(DietPlanItemRepository dietPlanItemRepository) {
        this.dietPlanItemRepository = dietPlanItemRepository;
    }

    public List<DietPlanItem> findAll() {
        return dietPlanItemRepository.findAll();
    }

    public Optional<DietPlanItem> findById(Long id) {
        return dietPlanItemRepository.findById(id);
    }

    public DietPlanItem save(DietPlanItem dietPlanItem) {
        return dietPlanItemRepository.save(dietPlanItem);
    }

    public void deleteById(Long id) {
        dietPlanItemRepository.deleteById(id);
    }

    public List<DietPlanItem> findByDietPlanId(Long dietPlanId) {
        return dietPlanItemRepository.findByDietPlanId(dietPlanId);
    }
} 